package com.chen.product.controller;

import com.chen.model.entity.product.Category;
import com.chen.model.vo.common.Result;
import com.chen.model.vo.common.ResultCodeEnum;
import com.chen.product.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author cgj
 * @date 4/13/25 8:59 AM
 */
@RestController
@RequestMapping("/api/product/category")
//@CrossOrigin    使用网关处理跨域,这个就不需要了,写了会出错
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    /**
     * 获取分类树形结构
     * @return
     */
    @GetMapping("/findCategoryTree")
    public Result<List<Category>> findCategoryTree(){
        List<Category> categoryList= categoryService.findCategoryTree();
        return Result.build(categoryList, ResultCodeEnum.SUCCESS);
    }
}
